package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ProductApiService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @Author: 赵勇镔
 * @Time: 2021/5/17 10:46
 * @Description:
 */
@RestController
@RequestMapping("/api/product")
public class ProductApiController {

    @Autowired
    private ProductApiService productApiService;


    @ApiOperation("通过商品id获取库存信息")
    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId) {

        return productApiService.getSkuInfo(skuId);
    }

    @ApiOperation("查询一二三级分类")
    @GetMapping("/inner/getBaseCategoryView/{category3Id}")
    public BaseCategoryView getBaseCategoryView(@PathVariable Long category3Id) {
        return productApiService.getBaseCategoryView(category3Id);

    }

    @ApiOperation("销售属性值以及选中")
    @GetMapping("/inner/getSpuSaleAttrValueChecked/{skuId}/{spuId}")
    public List<SpuSaleAttr> getSpuSaleAttrValueChecked(@PathVariable Long skuId,
                                                        @PathVariable Long spuId) {
        return productApiService.getSpuSaleAttrValueChecked(skuId, spuId);

    }

    @ApiOperation("销售属性值组合对应库存id")
    @GetMapping("/inner/getValuesSkuJson/{spuId}")
    public Map getValuesSkuJson(@PathVariable Long spuId) {
        return productApiService.getValuesSkuJson(spuId);
    }

    @ApiOperation("单独查询价格,不放在缓存中")
    @GetMapping("/inner/getPrice/{spuId}")
    public BigDecimal getPrice(@PathVariable Long spuId) {
        return productApiService.getPrice(spuId);
    }

    @ApiOperation("查询三阶分类视图集合")
    @GetMapping("/inner/getBaseCategoryViewList")
    public List<BaseCategoryView> getBaseCategoryViewList(){
        return productApiService.getBaseCategoryViewList();
    }

    @ApiOperation("查询品牌对象")
    @GetMapping("/inner/getBaseTrademark/{id}")
    public BaseTrademark getBaseTrademark(@PathVariable Long id){
        return productApiService.getBaseTrademark(id);
    }

    @ApiOperation("查询Es索引库所需要的平台属性ID,名称及值")
    @GetMapping("/inner/getSkuAttrValue/{skuId}")
    public List<SkuAttrValue> getSkuAttrValue(@PathVariable Long skuId){
        return productApiService.getSkuAttrValue(skuId);
    }


}
